/*
 * @Author: zi.yang
 * @Date: 2021-09-27 15:34:18
 * @LastEditors: zi.yang
 * @LastEditTime: 2021-09-27 15:46:07
 * @Description: In User Settings Edit
 * @FilePath: \project-management\utils\ormErrorMessage.js
 */
module.exports = function (err) {
  const error = err.errors[0];
  let message = '';
  switch (error.type) {
    case 'Validation error':
      message = error.message;
      break;
    case 'unique violation':
      message = `字段：${error.path.replace(
        /_.*/,
        ''
      )} 有唯一约束，值不能重复！`;
      break;
    default:
      message = 'error';
      break;
  }
  return message;
};
